/**
 * @file esn.h
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2022-02-17
 *
 * @copyright Copyright (c) 2022
 *
 */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __ESN_H
#define __ESN_H

#include <stdint.h>
#include <linux/spi/spidev.h>
#include "mqtt_client.h"

#define SPI_MODE SPI_MODE_3 //mode2
#define SPI_SPEED 2000000	//2MHz
#define DEV_NAME "/dev/spi-encrypt"


//The SSX1805 only supports spi mode 3
#define SPI_SSX_MODE        SPI_MODE_3   
#define SPI_SPEED_HZ        10000      
#define SPI_BIT_PER_WORD    8
#define SPI_DELAY_USECS     0
#define chip_selected 0     //低电平
#define chip_release 1		//高电平
/* ioctl */
#define SPI_IOC_CS_MODE     _IOR(SPI_IOC_MAGIC, 18, __u32)

#define CMD_APPM_L			"appm -l -n SecurityProxy"
#define STR_SECURITYPROXY	"SecurityProxy"

/**
 * @brief encrypt_sn_data
 *
 */
#pragma pack(push)
#pragma pack(1)

typedef enum
{
	Invaild_type = -1,
    ssx1801 =1,
	sc1161y,
	encrypt_type_max,
} encrypt_type;

typedef struct
{
	char sn[16];
	char chiptype[1];
} encrypt_info;

extern encrypt_info encrypt_t;

#pragma pack(pop)

extern uint8_t get_esn(char *put_buffer);
extern int spi_config(void);
extern int transfer(char   * tx,char* rx,unsigned int length);

#endif /* __ESN_H */

